function pic_size(t){if (t.width>g_width-30)t.style.width=(g_width-30)+'px';}//图片大小,图片载入时调用
function im() {var url='cb?gv=1';$('gv').src = url+"?" + parseInt(Math.random()*100);url=null; }//验证码刷新
function scroll()//主列表更多
{var _b=document.documentElement.clientHeight;var _d=document.body.clientHeight;var _e=(_b>_d?_d:_b);
var _a=document.body.scrollHeight;var _c=document.documentElement.scrollHeight;
if(current=='index' && ((_a>_c?_a:_c)<200+_e+(document.body.scrollTop ||document.documentElement.scrollTop)))vmore();_a=_b=_c=_d=_e=null;}
function addlist(t,i) //添加内容到列表
{var a=$$('article');var f=$$('figure');
f.innerHTML=t;if(i){f.onclick=Function(i);f.title=t.replace(/(.*?)\([\d关]*?\)/,'$1').replace(/.*?<br.*?:(.*)/,'$1');}
a.appendChild(f);$('app-list').appendChild(a);a=f=null;}
function showA(u)
{current='article';bar();if(u)art_id=u;document.title=art_title; showcontent();}
function showUrl(u,t){ //切换到文章
if(t)art_title=t.title; if(g_set['mode']!=1){showC(u);return;}showA(u);}
function showC(u)//直接评论
{art_id=u;current='article';move(1);}
function showArt() //显示文章
{$('cnbetacss').innerHTML=wait;hide('m_c');$('m_a').className='';$('m_b').className='';$('m_a').innerHTML='Double -5';$('m_b').innerHTML='Double +5';
$('m_a').onclick=Function("comment("+art_id+",-5,this)");$('m_b').onclick=Function("comment("+art_id+",5,this)");show('sub');
if(isAjax)return;var _url='/cb?ajax=1&a='+art_id+(g_set['pic']?'':'&pic=0');AJAX('GET',_url,null,function(x){$('cnbetacss').innerHTML=x;isAjax=false;});_url=null;}
function Mode(a)//更换sub的当前
{g_set['mode']=a;if(a==1){$('m_a').className='current';$('m_b').className='logClass';}else{$('m_b').className='current';$('m_a').className='logClass';}}
function bar() //顶部bar处理
{$('bar_c').innerHTML=g_name[current];hideURLbar();
if(g_list[current][0]=='')hide('bar_l');else {show('bar_l');$('bar_l').innerHTML=g_name[g_list[current][0]];}
if(g_list[current][1]=='')hide('bar_r');else {show('bar_r');$('bar_r').innerHTML=g_name[g_list[current][1]];}}
function move(a) //划屏
{if(isAjax||isMove)return;if(a==0){if(g_list[current][0]=='')return;current=g_list[current][0];}
else if(a==-1);else if(a==-2)current='set';else {if(g_list[current][1]=='')return;current=g_list[current][1];}isMove=true;if(current=='')current='index';
if(current=='send')tid=0;bar();showcontent();}
function comment(id,supp,t) //支持反对
{var a=t.innerHTML;var b=$$('script');
if(id!=2931){if (supp==5||supp==-5){b.src='/cb?rate='+id+'&ajax='+supp;}
else if(supp==-1)b.src='http://cnbeta.com/Ajax.report.php?tid='+id;
else b.src='http://cnbeta.com/Ajax.vote.php?tid='+id+'&'+(supp==1?'support':'against')+'=1';
$('cnbetacss').appendChild(b);$$$(b);}if(a.indexOf('点')<0)t.innerHTML=a+'[已点]';a=null;}
function Send(t,e) //发评
{e.preventDefault();AJAX('POST','cb','c='+escape(t.comment.value)+'&m='+t.im.value+'&i='+art_id+'&t='+tid,function(x)
{var a='';switch(x){case '0':a= '新闻已删';break;case '1':a= '验证码';break;case '2':a = '30秒';break;case "5":a= '成功.';break;default:a= '其他错误' ;}alert(a);});}
function vmore(){ //显示更多
if(list<500)return;flush('/cb?ajax=1&v='+list,3);}
function rely(i) //回复
{tid=(i==2931?0:i);current='send';bar();showcontent();}
function get_setting()
{$('app-list').innerHTML='';for(var i in g_set_map)addlist(g_set_map[i][g_set[i]],'set_setting(\''+i+'\',this)');}
function set_setting(a,b)
{var c=(g_set[a]?0:1);g_set[a]=c;b.innerHTML=g_set_map[a][c];}
